package cn.xinfei.xdecision.common.dynamic;

import java.util.Objects;

public enum DataSourceType {
    data("xdecision-engine-server"),
    exam("xdecision-exam-server");
    public String serverName;

    DataSourceType(String serverName) {
        this.serverName = serverName;
    }

    public static void main(String[] args) {
        System.out.println(DataSourceType.get("xdecision-exam-server"));
        System.out.println(DataSourceType.get("xdecision-engine-server"));
    }

    public static DataSourceType get(String serverName) {
        if (Objects.isNull(serverName)) {
            return data;
        }
        for (DataSourceType e : DataSourceType.values()) {
            if (serverName.equals(e.serverName)) {
                return e;
            }
        }
        return data;
    }
}
